<?php
class FilterType implements Zend_Filter_Interface{
	public function filter( $value ){
		return gettype( $value );
	}
}
class Test_CV_Zend_Filter_Input extends UnitTestCase{
	function test_filter(){
		/**
		 * Filter for test purposes
		 */
		
		// input used in tests
		$input = array( 'test' => array('a'=>array('a1')) );
		
		// typical filter definition
		$filters = array(
			'test' => array(new FilterType)
		);
		
		// Testing traverseArray enabled (default)
		$i = new CV_Zend_Filter_Input(	$filters, array(), $input );
		$expected_result = array(
			'test' => array( 'a' => 'array' )
		);
		$this->assertEqual( $expected_result, $i->getEscaped() );
		
		// Testing traverseArray disabled
		$i = new CV_Zend_Filter_Input(	$filters, array(), $input, array('traverseArray' => false) );
		$expected_result = array(
			'test' => 'array'
		);
		$this->assertEqual( $expected_result, $i->getEscaped() );
		
		// Testing recursive strategy filtering values
		$filters = array(
			'test' => array( new CV_Zend_Filter_ArrayRecurse(new FilterType) )
		);
		$i = new CV_Zend_Filter_Input(	$filters, array(), $input, array('traverseArray' => false) );
		$expected_result = array(
			'test' => array( 'a' => array('string') )
		);
		$this->assertEqual( $expected_result, $i->getEscaped() );
		
		// Testing recursive strategy filtering keys
		$filters = array(
			'test' => array( new CV_Zend_Filter_ArrayRecurseKeys(new FilterType) )
		);
		$i = new CV_Zend_Filter_Input(	$filters, array(), $input, array('traverseArray' => false) );
		$expected_result = array(
			'test' => array( 'string' => array('integer' => 'a1') )
		);
		$this->assertEqual( $expected_result, $i->getEscaped() );
					
	}
}
